<template>
  <div :style="{height: tabHeight + 'px'}">
    <el-tabs v-model="activeName" @tab-click="handleClick">
      <el-tab-pane label="普通会议" name="first">
        <!--表格渲染-->
        <meet-creat-table-comp v-show="activeName === 'first'" ref="meetCreate" :local-height="tableHeight"></meet-creat-table-comp>
      </el-tab-pane>
      <el-tab-pane label="周期会议" name="second">
        <peroid-meeting-table-comp v-show="activeName === 'second'" ref="peroidMeeting" :local-height="tableHeight"></peroid-meeting-table-comp>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
/** mixins */
import { mixin_list } from '@tapui/mixins/mixin_list'
/** 子组件 */
import tlEdit from './edit'
import tlRefMeetType from '../meetTypeManage/refMeetType'
import meetCreatTableComp from "@/views/meet/meetManage/meetCreatTableComp"
import peroidMeetingTableComp from "@/views/meet/meetManage/peroidMeetingTableComp"
/** 工具类 */
import { getAction, putAction, postAction, deleteAction } from '@tapui/utils/http'
export default {
  name: 'meetPeroidTask',
  mixins: [mixin_list],
  components: { tlEdit, tlRefMeetType, meetCreatTableComp, peroidMeetingTableComp },
  data() {
    return {
      description: '会议周期任务-列表查询',
      urlPrefix: '/meet/peroidTask/',
      url: {
        queryCodeList: '/meet/peroidTask/dataCodeList',
        queryMeetTypeList: '/meet/typeManage/queryTreeList'
      },
      // 排序参数
      sorterInfo: {
        sidx: 'id',
        sord: 'desc'
      },
      meetType: [],
      meetTypeList: [],
      activeName: 'first',
      tableHeight: 1000,
      isQueryOnCreated: false
    }
  },
  props: {
    tabHeight: {
      type: Number,
      default: 0
    }
  },
  watch: {
    tabHeight: {
      handler(newV, oldV) {
        this.tableHeight = newV - 100
      },
      deep: true
    }
  },
  methods: {
    /** 限制删除*/
    doLimitDelete(data) {
      if (data.state === 1) {
        this.$tap.alert('发布的会议不允许删除！', 'warning')
        return
      }
      this.doDelete(data.id)
    },
    handleMeetTypeChange(value) {
      this.queryParam.qry_meettypeid = value[value.length - 1]
    },
    // 切换tab页
    handleClick(data) {
      this.$emit('activeTab', data.name)
      if (data.name === 'first') {
        this.$nextTick(() => {
          this.$refs.meetCreate.doSearch()
        })
      }
      if (data.name === 'second') {
        this.$nextTick(() => {
          this.$refs.peroidMeeting.doSearch()
        })
      }
    },
    doSearch(param) {
      if (this.activeName === 'first') {
        this.$refs.meetCreate.queryParam = param
        this.$set(this.$refs.meetCreate.pageInfo, 'currentPage', 1)
        this.$refs.meetCreate.loadData({})
      }
      if (this.activeName === 'second') {
        this.$refs.peroidMeeting.queryParam = param
        this.$refs.peroidMeeting.loadData({})
      }
    }
  },
  created() {
    /** 查询树 */
    getAction(this.url.queryMeetTypeList, { isAddRoot: false }).then((res) => {
      if (res.success) {
        let reg = new RegExp('id', 'g') // g代表全部
        this.meetTypeList = JSON.parse(JSON.stringify(res.result.dataList).replace(reg, 'value'))
      }
    })
  }
}
</script>

<style scoped></style>
